package app.controllers.customer;

import app.models.member.Member;
import app.models.member.MemberIntegralRecord;
import com.github.sog.controller.AjaxMessage;
import com.github.sog.controller.BasicController;
import com.github.sog.controller.datatables.core.DatatablesCriterias;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

/**
 * <p>
 *     积分变更
 * </p>
 *
 * @author Jerry Ou
 * @version 1.0 2014-06-07 13:06\
 * @since JDK 1.6
 */
public class IntegralRecordController extends BasicController {

    public void index() {
        render("index.ftl");
    }

    public void list() {
        final Member member = getModel(Member.class, "member");
        final String recordDate = getPara("recordDate");
        final DatatablesCriterias criterias = getCriterias();

        Page<Record> recordPage = MemberIntegralRecord.dao.customerRecods(criterias, member, recordDate);

        renderDataTables(recordPage, criterias);
    }

    public void confirm() {
        long id = getParaToLong("id", 0l);

        MemberIntegralRecord record = new MemberIntegralRecord();
        record.set("id", id);
        record.set("status", true);
        record.update();

        renderJson(AjaxMessage.ok("操作成功"));
    }

}
